#pragma once
#include"RBTree.h"
namespace egghead
{
	template<class K, class V>
	class map
	{
		struct GETVAL { const K& operator()(const pair<const K,V>& kv) { return kv.first; } };
		typedef typename RBTree<K, pair<const K,V>, GETVAL>::Iterator Iterator;
		typedef typename RBTree<K, pair<const K, V>, GETVAL>::const_Iterator const_Iterator;

	public:
		pair<Iterator, bool> insert(const pair<K,const V>& kv) { return _tree.insert(kv); }
		V& operator[](const K& key) 
		{ 
			pair<Iterator, bool>ret = insert({ key, V() });
			return ret.first->second;
		}
		void inorder() { _tree.inorder(); cout << endl; }
		size_t size() { return _tree.size(); }
		bool checktree() { return _tree.checktree(); }
		Iterator begin() { return _tree.begin(); }
		Iterator end() { return _tree.end(); }
		const_Iterator begin() const{ return _tree.begin(); }
		const_Iterator end() const{ return _tree.end(); }

	private:
		RBTree<K, pair<const K,  V>,GETVAL>_tree;
	};
}